package VO;

import java.util.ArrayList;
import User.User;
import User.UserList;

public class UserListVO {
	ArrayList<UserVO> Userlist = new ArrayList<UserVO>();
	String userID="";
	
	public UserListVO(){}
	
	public UserListVO(ArrayList<UserVO>  ulist){
		Userlist=ulist;
		init();
	}
	public UserListVO(UserList  userlist){
		for(User u: userlist.getUserlist()){
			UserVO uservo=new UserVO(u);
			Userlist.add(uservo);
		}
		userID=userlist.getUserID();
	}
	public UserListVO(String userlistinfo[][]){
		for(String userinfo[]:userlistinfo){
			UserVO user=new UserVO(userinfo);
			Userlist.add(user);
		}
	}
	
	public UserListVO(UserListVO userlOfAll,String useridList){
		String[] uidlist=useridList.split("/");
		if(useridList.equals("")){
			for(String id:uidlist){
				UserVO uservo=userlOfAll.find(Long.parseLong(id));
				Userlist.add(uservo);
			}
			init();
		}
		
	}
	public void init(){
		for(UserVO user:Userlist){
			userID=userID+"/"+user.getId();
		}
	}
	public UserVO find(long id){
		UserVO user=null;
		for(UserVO uv:Userlist){
			if(uv.getId()==id){
				user=uv;
				break;
			}
		}
		return user;
	}
	public ArrayList<UserVO> getUserlist(){
		return Userlist;
	}
	public String getUserlid(){
		return userID;
	}
	

}
